package com.dana.gomoku.model;

import com.dana.gomoku.enums.ResultStatus;
import lombok.Data;

@Data
public class Result <T>{
    private ResultStatus status;
    private Integer code;
    private String ErrMsg;
    private T data;


    public static <T> Result<T> success(T data){
        Result result=new Result();
        result.setCode(200);
        result.setData(data);
        result.setStatus(ResultStatus.SUCCESS);
        result.setErrMsg("");
        return result;
    }

    public static <T> Result<T> fail(String errMsg){
        Result result=new Result();
        result.setErrMsg(errMsg);
        result.setCode(-1);
        result.setStatus(ResultStatus.FAIL);
        return result;
    }
}
